935c22b60ddf12af5b9b40146879ab82c2aab859,src/main/java/org/jtwig/render/expression/calculator/MapSelectionExpressionCalculator.java,MapSelectionExpressionCalculator,calculate,#RenderRequest#MapSelectionExpression#,11

Before Change


        Converter<WrappedCollection> collectionConverter = request.getEnvironment().getValueEnvironment().getCollectionConverter();

        Object mapExpressionValue = calculateExpressionService.calculate(request, expression.getMapExpression());
        WrappedCollection collection = collectionConverter.convert(mapExpressionValue).orThrow(expression.getPosition(), String.format("Cannot convert %s to a map", mapExpressionValue));

        Object calculate = calculateExpressionService.calculate(request, expression.getSelectValue());
        return collection.getValue(getString(request, calculate));

After Change


        Converter<WrappedCollection> collectionConverter = request.getEnvironment().getValueEnvironment().getCollectionConverter();

        Object mapExpressionValue = calculateExpressionService.calculate(request, expression.getMapExpression());
        Converter.Result<WrappedCollection> wrappedCollectionResult = collectionConverter.convert(mapExpressionValue);

        if (!wrappedCollectionResult.isDefined()) {
            throw new CalculationException(errorMessage(expression.getPosition(), String.format("Cannot convert %s to a map", mapExpressionValue)));
        }

        WrappedCollection collection = wrappedCollectionResult.get();

        Object calculate = calculateExpressionService.calculate(request, expression.getSelectValue());
        return collection.getValue(getString(request, calculate));